package com.example.demo.controller;

import com.example.demo.annotation.Idempotent;
import com.example.demo.service.IdempotentService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
public class HelloController {

    @Resource
    private IdempotentService idempotentService;

    @RequestMapping("/token")
    public Map<String, String> getToken(){
        return idempotentService.createToken();
    }

    @Idempotent
    @RequestMapping("/hello")
    public Map<String,Object> hello(String name, Integer age){
        System.out.println(name+"  "+age);

        Map<String,Object> result = new HashMap<>();
        result.put("code","000000");
        result.put("status","success");

        return result;
    }
}
